#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <unistd.h>
#include <strings.h>
#include <stdlib.h>
void str_cli(FILE* fp, int sockfd) {
	char sendline[1024];
	char recvline[1024];
	while (fgets(sendline, 1024, fp)) {
		write(sockfd, sendline, 1024);
		read(sockfd, recvline, 1024);
		fputs(recvline, stdout);
	}
}

int main(int argc, char** argv) {
	int sockfd;
	sockaddr_in servaddr;
	sockfd = socket(AF_INET, SOCK_STREAM, 0);
	bzero(&servaddr, sizeof(servaddr));
	servaddr.sin_family = AF_INET;
	servaddr.sin_port = htons(10002);
	inet_pton(AF_INET, argv[1], &servaddr.sin_addr);
	connect(sockfd, (sockaddr*)&servaddr, sizeof(servaddr));
	str_cli(stdin, sockfd);
	exit(0);
}
